package com.woniuxy.rms.service.impl;

import com.woniuxy.rms.dao.CarouselMapper;
import com.woniuxy.rms.pojo.Carousels;
import com.woniuxy.rms.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService {


    @Autowired
    CarouselMapper carouselsMapper;

    @Override
    public List<Carousels> findAll(Integer currentPage, Integer pageSize) {

        return carouselsMapper.findAll(currentPage,pageSize);
    }

    @Override
    public void save(Carousels carousels) {
        carousels.setCreateTime(new Date());
        carouselsMapper.insertSelective(carousels);
    }

    @Override
    public Carousels getCarousel(Byte id) {
        return carouselsMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateCarousel(Carousels carousels) {
        carouselsMapper.updateByPrimaryKeySelective(carousels);
    }

    @Override
    public void updateStatusById(Byte cid, Integer status) {
        carouselsMapper.updateStatusById(cid,status);
    }

    @Override
    public void delById(Byte id) {
        carouselsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void batchDelById(List<Long> id) {
        carouselsMapper.batchDel(id);
    }

    @Override
    public List<Carousels> findByStatus() {
        return carouselsMapper.findByStatus();
    }
}